﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsTheme.Helper
{
    public partial class ThemeCreate : Form
    {
        public ThemeCreate()
        {
            InitializeComponent();
            InitData();
            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
        }

        private void InitData()
        {
           
            string[] dirs = Directory.GetFiles(StaticValue.Win7SucessTheme, "*.themepack");
            //取列表
            foreach (string item in dirs)
            {
                Console.WriteLine(item);
                this.comboBox1.Items.Add(Path.GetFileNameWithoutExtension(item));
                Console.WriteLine(comboBox1.Items.Count);
            }
            if (comboBox1.Items.Count>0) {
                comboBox1.SelectedIndex = 0;
            }
          

        
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String Package = StaticValue.Win7SucessTheme+"Package\\已打包"+comboBox1.Text+"\\";

            String PackageBin = Package + "Bin\\";
            String ThemeFileName = StaticValue.Win7SucessTheme + comboBox1.Text + ".themepack";
            FileHelper.Folder_existence(PackageBin, true);
            if (!FileHelper.FileCopy(ThemeFileName, PackageBin+ "instatll.themepack"))
            {
                MessageBox.Show("复制主题安装包文件失败！");
            }
            if (!FileHelper.FileCopy(StaticValue.ThemePath+comboBox1.Text + "\\ThemeInfo.xml", PackageBin + "ThemeInfo.xml"))
            {
                MessageBox.Show("无主题xml");
            }
           
            if (!FileHelper.FileWrite(Package + "Win7-8安装助手.exe", Resource1.Win7Helper))
             {
                MessageBox.Show("Win7安装引导创建失败！！");
            }
            if (!FileHelper.FileWrite(Package + "Win10安装助手.exe", Resource1.Win10Helper))
            {
                MessageBox.Show("Win10安装引导创建失败！！");
            }
            FileHelper.OpenFile(Package);
        }
    }
}
